﻿/**
 *	html/pem_data_event.js
 *
 *	(C) 2014 Yuanjj
 *
 * 	history:
 * 		2014-08-16		create the file
 */

/**
 *	init event
 */
function init_event()
{
    _create_event_type();
    _create_event();
}

/**
 *	create event type store
 */
var g_event_type;
function _create_event_type()
{
    Ext.define
    ("model_event_type",{
         extend:"Ext.data.Model",
         fields:[
             {name:"serial",	type:"int"},
             {name:"type",		type:"string"}
         ]
    });

    g_event_type = new Ext.data.ArrayStore
    ({
         autoLoad:true,
         model:"model_event_type",
    });
}

/**
 *	create event store
 */
var g_event;
function _create_event()
{
    Ext.define
    ("model_event_store",{
         extend:"Ext.data.Model",
         fields:[
             {name:"serial",	type:"int"},
             {name:"type",		type:"string"},
             {name:"datetime",	type:"string"},
             {name:"user",		type:"string"},
             {name:"descript",	type:"string"},
         ]
    });

    g_event = new Ext.data.ArrayStore
    ({
         autoLoad:true,
         model:"model_event_store",
    });
}

/**
 *	callback for setting event type
 */
function callback_set_event_type( serial, type )
{
    var index = g_event_type.count();

    g_event_type.insert( index, [[serial, type]] );
}

/**
 *	callback for setting event
 */
function callback_set_event( serial, type, date, user, descript )
{
    var index = g_event.count();

    g_event.insert( index, [[serial, type, date, user, descript]] );
}
